In [1]:
from numpy.linalg import inv
import numpy as np
import matplotlib.pyplot as plt
from sklearn.datasets import make_blobs

from diffmaps_util import k, diag

Generating a set X with 900 samples


In [6]:
centers = [[-1,0], [1,1], [1,-1]]
X, labels = make_blobs(n_samples=900, centers=centers, cluster_std=.4, random_state=0)
x, y = X[:,0], X[:,1]

In [3]:
plt.scatter(x, y, c=labels)
plt.title('Original Dataset')
plt.show()



In [4]:
L = k(X, .1)
D = diag(L)
M = inv(D).dot(L)

Random walking


In [5]:
e = np.zeros(900); e[0] = 1
i = 1
for t in range(1,2048+1):
    e = e.dot(M)
    if t in [1, 8, 64, 1024, 2048]:
        plt.figure(i, figsize=(10,10))
        plt.subplot(211)
        plt.title('epsilon = %.1f & t=%d' % (.1, t))
        plt.scatter(X[:,0], X[:,1], c=e, cmap='copper')
        i += 1
plt.show()